﻿using fmtx.Framework.NoSqlHelper;
using PressureTest.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;

namespace PressureTest
{
    public partial class UserLogForm : Form
    {
        MongoOperation<UserInfoLog> userdb = new MongoOperation<UserInfoLog>();
        bool achange = false;
        bool onechange = false;
        public UserLogForm()
        {
            CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
            ShowData();
        }

        private void ShowData()
        {
            var bg=Convert.ToInt32(txtbg.Text);
            var en=Convert.ToInt32(txten.Text);
            var list=userdb.AllList();
            if (cbxsx.Text.ToLower() == "error")
            {
                list = list.Where(w => !string.IsNullOrEmpty(w.Error));
            }
            if (cbxsx.Text.ToLower() == "success")
            {
                list = list.Where(w => string.IsNullOrEmpty(w.Error) && w.StatuCode == HttpStatusCode.OK);
            }
            list = list.Skip(bg).Take(en);
            try
            {
                dgv.DataSource = list.ToList();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }

        private void btngo_Click(object sender, EventArgs e)
        {
            ShowData();
        }
    }
}
